﻿using A.M.ETO;
using L.M.System.Application.IServices;
using L.M.System.Domain.DTO;
using L.M.System.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Redis_ClientInfor;

namespace L.M.System.Read.API.Controllers
{
    /// <summary>
    /// 交付地址
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Delivery_addressReadController : ControllerBase
    {
        private readonly IDelivery_addressServices delivery_AddressServices;
        public Delivery_addressReadController(IDelivery_addressServices delivery_AddressServices)
        {
            this.delivery_AddressServices = delivery_AddressServices;
        }

        /// <summary>
        /// 交付地址查询 + 分页
        /// </summary>
        /// <param name="pageSize">每页条数</param>
        /// <param name="pageIndex">当前页索引</param>
        /// <param name="tName">查询条件</param>
        /// <returns>交付地址查询 + 分页</returns>
        [HttpGet]
        public async Task<IActionResult> GetDelivery_addressRead(int pageSize, int pageIndex, string? tName)
        {
            var list = await delivery_AddressServices.GetDelivery_addressRead(pageSize, pageIndex, tName);
            return Ok(list);
        }


        /// <summary>
        /// 地址添加
        /// </summary>
        /// <param name="addAdderInforDTO">DTO</param>
        /// <returns>统一返回格式</returns>
        [HttpPost]
        public async Task<IActionResult> AddAdderInfor(AddAdderInforDTO addAdderInforDTO)
        {
            return Ok(await delivery_AddressServices.AddAdderInfor(addAdderInforDTO));
        }


        /// <summary>
        /// 删除地址
        /// </summary>
        /// <param name="aId">地址编号</param>
        /// <returns>统一返回格式</returns>
        [HttpDelete]
        public async Task<IActionResult> DelInforAdder(string? aId)
        {
            return Ok(await delivery_AddressServices.DelInforAdder(aId));
        }

        /// <summary>
        /// 修改默认地址
        /// </summary>
        /// <param name="rId">编号</param>
        /// <returns>修改默认地址</returns>
        [HttpPut]
        public async Task<IActionResult> GteUpdSattyInfor(string? rId)
        {
            return Ok(await delivery_AddressServices.GteUpdSattyInfor(rId));
        }
    }
}
